// 搜索模块 例子
import { ActionTree, MutationTree, GetterTree, ActionContext } from 'vuex'
import { RootStateTypes } from '../types'

export const namespaced = true
export const name: string = "search"

interface SearchInterface {
  name: string
}

const types = {
  SET_NAME: 'SET_NAME'
}

export const state: SearchInterface = {
  // 检索产品名字
  name: ''
}

export const getters: GetterTree<SearchInterface, RootStateTypes> = {
  name: state => state.name
}

export const mutations: MutationTree<SearchInterface> = {
  [types.SET_NAME](state,name:string) {
    state.name = name
  }
}
export const actions: ActionTree<SearchInterface, RootStateTypes> = {
  setName({ commit }, name) {
    commit(types.SET_NAME, name);
  }
}

export default { namespaced, state, actions, mutations };